#!/bin/bash

echo '[info] begin to split data into several partitions...'
if [ -z $1 ]
then
    exit 0
fi
if [ -z $2 ]
then
    exit 0
fi
workingDir=$1
inputFile=$2

mkdir -p ${workingDir}/split
cd ${workingDir}
rm -rf train test
mkdir -p train test
# partition
partition=10
lineNum=`wc -l ${inputFile} | awk -F' ' '{printf $1"\n"}'`
linePerPartition=$((lineNum / partition + 1))
sort -R ${inputFile} | split -a2 -l${linePerPartition}
mv -f xa* split

echo '[info] end of spliting data into several partitions...'
